<?php
namespace Home\Controller;
use Think\Controller;
class VideoController extends CommonController {
     
     //浏览视频信息
    public function index(){

       $mod = M('video');
       $count = $mod->count();// 查询满足要求的总记录数
       
       $Page = new \Think\PageHome($count,9);// 实例化分页类 传入总记录数和每页显示的记录数(25)

       // $Page -> setConfig('header','共%TOTAL_ROW%条');
       $Page -> setConfig('first','<<');
       // $Page -> setConfig('last','共%TOTAL_PAGE%页');
       $Page -> setConfig('prev','<');
       $Page -> setConfig('next','>');
       $Page -> setConfig('link','indexpagenumb');//pagenumb 会替换成页码
       $Page -> setConfig('theme','%FIRST% %UP_PAGE% %NOW_PAGE%/%TOTAL_PAGE% %DOWN_PAGE% %END%');
       
       $show = $Page->show();// 分页显示输出
       // 进行分页数据查询 注意limit方法的参数要使用Page类的属性
       $video = $mod->order('video.addtime desc')->limit($Page->firstRow.','.$Page->listRows)->select();

       //放置模板中
       
       $this->assign("video",$video);
       $this->assign('page',$show);// 赋值分页输出
       $this->assign('title','视频中心');
       //加载模板输出
       $this->display("index");
    }

    //详情页
    public function detail(){
        

        $mod =M("video"); 
        $id = I('get.id/d');
        $mod->where('id='.$id)->setInc('click');
        $video = $mod->find($id);
        //推荐视频
        $recommend = $mod->order('click desc')->limit(3)->select();
        //放置模板中
        $this->assign('keywords',$video['keywords']);
        $this->assign('description',$video['description']);
        $this->assign("v",$video);
        $this->assign("recommend",$recommend);
        $this->assign('title',$video['name'].'　|　视频中心');
        //加载编辑模板
        $this->display("detail");
    }

}